﻿using Gaf;

using Microsoft.Extensions.DependencyInjection;

using System.Reflection;


//1. 创建插件框架
var gaf = GafManager.Create();
var addinManager = gaf.AddinManager;

////2. 注册事件
gaf.AddinStateChanged += Framework_AddinChanged;
void Framework_AddinChanged(IAddin e)
{
    Console.WriteLine($"[{e.Name}] 插件状态发生了变化:{e.State }");
}


//3. 配置安装插件
ServiceCollection services = new();
gaf.Configure(services);

//addinManager.Addins.ToList().ForEach(x => Console.WriteLine(x));

//4. 启动框架
var serviceProvider = services.BuildServiceProvider();
gaf.Start(serviceProvider);
//addinManager.Addins.ToList().ForEach(x => Console.WriteLine(x));


//关闭框架
gaf.Shutdown();
//addinManager.Addins.ToList().ForEach(x => Console.WriteLine(x));